#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/statistics"

samples = {}

def show_samples(samples)
  samples.each do |k, v|
    puts "#{k}: #{v.sum}"
  end
  samples.clear
end

$stdin.each_line do |line|
  case line
  when /^time: /
    show_samples samples
  when /(^zone\d): (.*)/
    samples[$1] ||= []
    samples[$1] << $2.to_i
  when /(^cdev\d): (.*)/
    samples[$1] ||= []
    samples[$1] << $2.to_i
  end
end

show_samples samples
